package com.yqyd.web.controller.hy.web;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yqyd.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yqyd.common.annotation.Log;
import com.yqyd.common.core.controller.BaseController;
import com.yqyd.common.core.domain.AjaxResult;
import com.yqyd.common.enums.BusinessType;
import com.yqyd.hy.domain.HyManifest;
import com.yqyd.hy.service.IHyManifestService;
import com.yqyd.common.utils.poi.ExcelUtil;
import com.yqyd.common.core.page.TableDataInfo;

/**
 * 用户提交的货单Controller
 * 
 * @author Dhq
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/hy/manifest")
public class HyManifestController extends BaseController
{
    @Autowired
    private IHyManifestService hyManifestService;

    /**
     * 查询用户提交的货单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HyManifest hyManifest)
    {
        startPage();
        List<HyManifest> list = hyManifestService.selectHyManifestList(hyManifest);
        return getDataTable(list);
    }

    /**
     * 导出用户提交的货单列表
     */
    @Log(title = "用户提交的货单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HyManifest hyManifest)
    {
        List<HyManifest> list = hyManifestService.selectHyManifestList(hyManifest);
        ExcelUtil<HyManifest> util = new ExcelUtil<HyManifest>(HyManifest.class);
        util.exportExcel(response, list, "用户提交的货单数据");
    }

    /**
     * 获取用户提交的货单详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hyManifestService.selectHyManifestById(id));
    }

    /**
     * 修改用户提交的货单
     */
    @Log(title = "用户提交的货单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HyManifest hyManifest)
    {
        return toAjax(hyManifestService.updateHyManifest(hyManifest));
    }

    /**
     * 删除货单
     */
    @Log(title = "删除货单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public R<String> remove(@PathVariable Long id)
    {
        hyManifestService.deleteHyManifestById(id);
        return R.ok();
    }

}
